<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="net.sf.json.JSONObject,weaver.conn.RecordSet" %>
<%@ page import="weaver.conn.RecordSetDataSource" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%
	BaseBean bb= new BaseBean();

	Map<String, String> dataMap = new HashMap<String, String>();
	bb.writeLog("====getVAl====");
	String bm = request.getParameter("bm").trim();
	String flag = request.getParameter("flag");
	String customer = "";
	String diamert = "";
	String product = "";
	String name = "";
	String ref = "";
	bb.writeLog("bm=="+bm);
	bb.writeLog("flag=="+flag);
	if(flag.equals("0")){
		 customer = getCustomer(bm);
		 bb.writeLog("111==="+customer);
		 diamert = getDiameter(bm);
		 bb.writeLog("111==="+diamert);
		 product = getProduct(bm);
		 bb.writeLog("1111==="+product);
		 name = getCustomername(customer);
	}else if(flag.equals("1")){
		 customer = getCustomer1(bm);
		 diamert = getDiameter1(bm);
		 product = getProduct1(bm);
		 name = getCustomername(customer);
	}else if(flag.equals("2")){
		 customer = getCustomer2(bm);
		 diamert = getDiameter2(bm);
		 product = getProduct2(bm);
		 name = getCustomername(customer);
		 ref = getRef(bm);
		
	}else if(flag.equals("3")){
		ref = getRef(bm);
	}
	bb.writeLog("customer=="+customer);
	bb.writeLog("diamert=="+diamert);
	bb.writeLog("product=="+product);
	bb.writeLog("name=="+name);
	dataMap.put("customer",customer);
	dataMap.put("diamert",diamert);
	dataMap.put("product",product);
	dataMap.put("name",name);
	dataMap.put("ref",ref);
	JSONObject json = JSONObject.fromObject(dataMap);
	out.print(json.toString());
%>
<%! 

public String getCustomername(String str){
	String ret = "";
	RecordSetDataSource rsd = new RecordSetDataSource("CSK");
	String sql = "select nvl(name1,name2) as name from saptest.ma_sap_1201_dtl_bpmcust where partner='"+str+"' ";
	rsd.execute(sql);
	if(rsd.next()){
		ret = Util.null2String(rsd.getString("name"));
	}
	return ret;
}
public String getDiameter(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = "select diameter from uf_coqc where coqcformatname='"+str+"' ";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("diameter"));
	}
	return ret;
}
public String getProduct(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = "select producttype from uf_coqc where coqcformatname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("producttype"));
	}
	return ret;
}

public String getCustomer(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = " select customer from uf_coqc where coqcformatname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("customer"));
	}
	return ret;
}

public String getDiameter1(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = "select diameter from uf_labelmana1 where labelname='"+str+"' ";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("diameter"));
	}
	return ret;
}
public String getProduct1(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = "select producttype from uf_labelmana1 where labelname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("producttype"));
	}
	return ret;
}

public String getCustomer1(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = " select customer from uf_labelmana1 where labelname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("customer"));
	}
	return ret;
}

public String getDiameter2(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = "select diameter from uf_lasermark where lmname='"+str+"' ";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("diameter"));
	}
	return ret;
}
public String getProduct2(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = "select producttype from uf_lasermark where lmname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("producttype"));
	}
	return ret;
}

public String getCustomer2(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = " select customer from uf_lasermark where lmname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("customer"));
	}
	return ret;
}
public String getRef(String str){
	String ret = "";
	RecordSet rs = new RecordSet();
	String sql = " select refsemistd from uf_lasermark where lmname='"+str+"'";
	rs.execute(sql);
	if(rs.next()){
		ret = Util.null2String(rs.getString("refsemistd"));
	}
	return ret;
}
%>

	